import 'package:baselib/utils/image_util.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';

class SendCommentWidget extends StatelessWidget {
  FocusNode commitFocusNode;
  Function onCommentChanged;
  Function sendMsgFunc;
  SendCommentWidget({Key key,this.commitFocusNode,this.onCommentChanged,this.sendMsgFunc}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AnimatedPadding(
      padding: MediaQuery.of(context).viewInsets,
      duration: Duration(milliseconds: 100),
      child: Container(
        width: PxUtil.instance.screenWidth,
        padding: EdgeInsets.only(
          bottom: PxUtil.instance.px_10,
          top: PxUtil.instance.px_10,
        ),
        color: ColorUtil.instance.color_304070,
        child: Row(
          children: [
            SizedBox(width: PxUtil.instance.px_15,),
            Expanded(
                child: Container(
                  height: PxUtil.instance.px_36,
                  alignment: Alignment.centerLeft,
                  decoration: BoxDecoration(
                      color: ColorUtil.instance.color_767F99,
                      borderRadius:
                      BorderRadius.circular(PxUtil.instance.px_18)),
                  child: TextField(
                    style: TextStyle(
                        color: ColorUtil.instance.color_white
                    ),
                    enabled: true,
                    textAlign: TextAlign.start,
                    maxLength: 200,
                    maxLines: 1,
                    textInputAction: TextInputAction.done,
                    keyboardType: TextInputType.text,
                    autofocus: true,
                    // focusNode: commitFocusNode,
                    // controller: model.commitTextController,
                    onChanged: (value)=>((onCommentChanged==null)?((){}):(onCommentChanged(value))),
                    cursorColor: ColorUtil.instance.color_white,
                    decoration: InputDecoration(
                        contentPadding: EdgeInsets.only(
                          left: PxUtil.instance.px_15,
                          right: PxUtil.instance.px_15,
                          bottom: PxUtil.instance.px_0,
                        ),
                        isDense: true,
                        counterText: "",
                        focusedBorder: UnderlineInputBorder(
                            borderSide: BorderSide(
                                color: ColorUtil
                                    .instance.color_transparent,
                                width: 1)),
                        enabledBorder: UnderlineInputBorder(
                            borderSide: BorderSide(
                                color: ColorUtil
                                    .instance.color_transparent,
                                width: 1))),
                  ),
                )),
            Container(
              margin: EdgeInsets.only(
                  left: PxUtil.instance.px_15,
                  right: PxUtil.instance.px_15,
              ),
              child: GestureDetector(
                onTap: (sendMsgFunc==null)?((){}):(()=>sendMsgFunc()),
                child: ImagesUtil.loadAssetImage(
                    DrawableUtil.instance.icon_send,
                    width: PxUtil.instance.px_25,
                    fit: BoxFit.fitWidth
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
